<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body style="padding:10px;">
<div class="tplay-body-div">
    {include file="application/application_tab"}
    <form class="layui-form" id="admin">
        <div class="layui-form-item">
            <label class="layui-form-label">所属部门：</label>
            <div class="layui-input-inline">
                <select name="cate_id" lay-search="">
                    {foreach $sectionCate as $p=>$ps}
                    <option value="{$p}" {notempty name="$cate_id"}{eq name="$cate_id" value="$p"} selected=""{/eq}{/notempty}>{$ps}</option>
                    {/foreach}
                </select>
            </div>

            <label class="layui-form-label">用户名称：</label>
            <div class="layui-input-inline">
                <select name="user_id" lay-search="">
                    {foreach $userRelation as $p=>$ps}
                    <option value="{$p}" {notempty name="$user_id"}{eq name="$user_id" value="$p"} selected=""{/eq}{/notempty}>{$ps}</option>
                    {/foreach}
                </select>
            </div>

        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">开始时间：</label>
            <div class="layui-input-inline">
                <input name="begin_time" id="begin_time" lay-verify="required" placeholder="选择开始时间" autocomplete="off" class="layui-input" type="text" {notempty name="$info.begin_time"} value="{$info.begin_time|date='Y-m-d',###}"{/notempty}>
            </div>
            <label class="layui-form-label">结束时间：</label>
            <div class="layui-input-inline">
                <input name="end_time" id="end_time"  lay-verify="required" placeholder="选择结束时间" autocomplete="off" class="layui-input" type="text" {notempty name="$info.end_time"} value="{$info.end_time|date='Y-m-d',###}"{/notempty}>
            </div>
            <div class="layui-input-inline">
                <span style="color: red">*30分钟为最小选择单元</span>
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">审批人：</label>
            <div class="layui-input-inline">
                <select name="relation_id" lay-search="" lay-verify="required">
                    <option value="请选择"></option>
                    {volist name="userRelation" id="vo"}
                    <option value="{$key}" >{$vo}</option>
                    {/volist}
                </select>
            </div>

            <label class="layui-form-label">请假类型：</label>
            <div class="layui-input-inline">
                <select name="application_status" lay-search="" lay-verify="required">
                    <option value="">请选择请假类型</option>
                    {volist name="statusAll" id="po"}
                    <option value="{$key}" name="">{$po}</option>
                    {/volist}
                </select>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">请假说明：</label>
            <div class="layui-input-inline">
                <textarea name="account"  style="width: 500px;height: 200px" placeholder="" class="layui-input"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>

    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script>
        layui.use(['layer', 'form'], function() {
            var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form;
            $(window).on('load', function() {
                form.on('submit(admin)', function(data) {
                    $.ajax({
                        url:"{:url('admin/application/publish')}",
                        data:$('#admin').serialize(),
                        type:'post',
                        async: false,
                        success:function(res) {
                            if(res == 1) {
                                layer.alert('未获取到用户信息，请重新登录！', function(index){
                                    document.location.reload();
                                })
                            }else if(res == 2){
                                layer.alert('参数缺失，请重试！', function(index){
                                    document.location.reload();
                                })
                            } else if(res == 3){
                                layer.alert('请选择有效的时间范围区间！', function(index){
                                    document.location.reload();
                                })
                            } else if(res == 5){
                                layer.alert('请教时长不得小于3小时！', function(index){
                                    document.location.reload();
                                })
                            } else if(res == 6){
                                layer.alert('请求时长超出范围！', function(index){
                                    document.location.reload();
                                })
                            }else if(res.code == 1) {
                                layer.msg(res.msg);
                                layer.msg(res.msg);
                                setTimeout(function(){
                                    document.location.reload();
                                },1500)
                            }
                        }
                    });
                    return false;
                });
            });
        });
    </script>

    <script>
        layui.use(['laydate','form'], function(){
            var laydate = layui.laydate;
            laydate.render({
                trigger: 'click',
                elem: '#begin_time',
                type:'datetime'
            });
            laydate.render({
                trigger: 'click',
                elem: '#end_time',
                type:'datetime'
            });
        });
    </script>
</div>
</body>
</html>